package com.smart.common.scheduler;

import com.smart.common.scheduler.service.TempTaskScheduleService;
import com.smart.common.scheduler.service.WeeklyTaskScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author macbook
 */
@Slf4j
@Component
public class WeeklyTaskAndTempTaskReportScheduler {

    @Autowired
    private TempTaskScheduleService tempTaskScheduleService;
    @Autowired
    private WeeklyTaskScheduleService weeklyTaskScheduleService;

    /**
     * 临时提报任务启动
     */
    @Scheduled(cron ="0 0 */1 * * ?")
    public void createTempTaskSchedule() {
        tempTaskScheduleService.createTempTask();
    }
    /**
     * 临时提报任务结束
     */
    @Scheduled(cron ="0 */1 * * * ?")
    public void finishTempTaskSchedule() {
        tempTaskScheduleService.finishTempTask();
    }
    /**
     * 周报提报任务
     * 每周一零点执行一次
     */
    @Scheduled(cron ="0 1 0 ? * MON")
    public void weeklyTaskSchedule() {
        log.info("createWeeklyTask...start");
        weeklyTaskScheduleService.createWeeklyTask();
        log.info("createWeeklyTask...end");
    }


}
